#ifndef __STRING__H__
#define __STRING__H__

extern unsigned char *str_chr(unsigned char *, char);
extern unsigned int str_to_ip(unsigned char *);
extern void str_array_flip(unsigned char *, int);
extern unsigned char *itoa_r(int, int, unsigned char *, int);
extern unsigned int atoi_r(unsigned char *, int);
extern void mem_set(unsigned char *, char, int);
extern void mem_zero(unsigned char *, int);
extern int mem_ncmp(unsigned char *, unsigned char *, int);
extern int endian_big_to_little(unsigned char *, int);

#define MEM_RW_8(p)			(*(char *)(p))
#define MEM_RW_16(p)			(*(short *)(p))
#define MEM_RW_32(p)			(*(int *)(p))

#define MEM_RW_U8(p)			(*(unsigned char *)(p))
#define MEM_RW_U16(p)			(*(unsigned short *)(p))
#define MEM_RW_U32(p)			(*(unsigned int *)(p))

#define MEM_B2L_8(p1, p2)		(*(char *)(p1) = endian_big_to_little((char *)(p2), 1))
#define MEM_B2L_16(p1, p2)		(*(short *)(p1) = endian_big_to_little((char *)(p2), 2))
#define MEM_B2L_32(p1, p2)		(*(int *)(p1) = endian_big_to_little((char *)(p2), 4))

#define MEM_B2L_U8(p1, p2)		(*(unsigned char *)(p1) = endian_big_to_little((unsigned char *)(p2), 1))
#define MEM_B2L_U16(p1, p2)		(*(unsigned short *)(p1) = endian_big_to_little((unsigned char *)(p2), 2))
#define MEM_B2L_U32(p1, p2)		(*(unsigned int *)(p1) = endian_big_to_little((unsigned char *)(p2), 4))

#endif